<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Album.aspx.cs" Inherits="Album" Title="My Photos" %>
<%@ Import Namespace="Friendster.Service" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <fs:FriendsterApplication runat="server" ID="fsApplication" ApplicationKey="0c868a9a9f2d332000cd09e1ed602ddc"
    ApplicationName="Creating .NET Client" Secret="7234cc4ad7689d0f8031b2023e252a3d" CallbackUrl="http://localhost:1653/StepByStep/" />
    <%
        
        
        if (Request["aid"] != null)
        {
            String aid = Request["aid"];
            bool success = fsApplication.Service.Photos.DeleteAlbum(Request["aid"], false);
           
            if (success)
            {
                Response.Write("The album is successfully deleted");
            }
            else
            {
                Response.Write("The album can not be deleted");
            }
        }
        
        
        Response.Write("<div style=\"padding-left:20px\"><strong>Creat Albums</strong><br /><br />");
        if (Request["aname"] != null)
        {
            bool ispvt = false;
            
            string name = Request["aname"];
            if (Request["isprivate"] != null)
            {
                if (Request["isprivate"].Equals("0"))
                    ispvt = false;
                else
                    ispvt = true;
            }
           
            Album albm = fsApplication.Service.Photos.CreateAlbum(name,ispvt);
        
        }
        Response.Write("<form name=\"creatAlbum\" method=\"post\",action=\"\">");
        Response.Write("<input type=\"text\" name=\"aname\" id=\"aname\" value=\"\"/>");
        Response.Write("<label><input type=\"radio\" name=\"isprivate\" id=\"isprivate\" value=\"0\"/>Public<label>");
        Response.Write("<label><input type=\"radio\" name=\"isprivate\" id=\"isprivate\" value=\"1\"/>Private<label><br>");
        Response.Write("<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Create Album\"/>");
        Response.Write("</form>");
        Response.Write("</div>");
        Response.Write("<div style=\"padding-left:20px\"><strong>My Albums</strong><br /><br />");
        Album[] albums = (Album[])fsApplication.Service.Photos.GetAlbumsOfUser();
        
        foreach (Album album in albums)
        {
            Response.Write("<form name=\"album_" + album.ID + "\" method=\"post\",action=\"\">");
            Response.Write("<input type=\"hidden\" name=\"aid\" id=\"aid\" value=\""+ album.ID+"\"/>");
            Response.Write("<strong>Album id: </strong>" + album.ID +"<br />");
            Response.Write("<strong>Cover picture id: </strong>" + album.CoverID + "<br />");
            Response.Write("<strong>Owner id: </strong>" + album.OwnerID + "<br />");
            Response.Write("<strong>Name: </strong>" + album.Name + "<br />");
            Response.Write("<strong>Creat Date: </strong>" + album.CreatedDate + "<br />");
            Response.Write("<strong>Modify date: </strong>" + album.ModifiedDate + "<br />");
            Response.Write("<strong>Description: </strong>" + album.Description + "<br />");
            Response.Write("<strong>Private album: </strong>" + album.IsPrivate + "<br />");
            Response.Write("<strong>Link: </strong>" + album.LinkUrl + "<br />");
            Response.Write("<strong>Size: </strong>" + album.Count + "<br />");
            if (!album.Name.Equals("My Public Photos") && !album.Name.Equals("My Private Photos"))
            {
                Response.Write("<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Delete this album?\"/>");
            }
            Response.Write("</form>");
        }
        Response.Write("</div>");
     %>
</asp:Content>